package app

import (
	"counter-help/admin/server/global"
	"github.com/gofrs/uuid/v5"
	"time"
)

// 小程序 用户登陆 Model
type AppUser struct {
	global.GVA_MODEL
	UUID     uuid.UUID  `json:"uuid" gorm:"index;comment:用户UUID"`
	Openid   string     `json:"openid"`
	NickName string     `json:"nickname" gorm:"column:nickname"`
	Phone    string     `json:"phone"`
	Address  string     `json:"address"`
	Username string     `json:"username" gorm:"column:username"`
	Password string     `json:"password" gorm:"column:password"`
	Birth    *time.Time `gorm:"column:birth"`
}

// TableName cusUser表 CusUser自定义表名 cus_user
func (AppUser) TableName() string {
	return "cus_user"
}

type Login interface {
	GetOpenid() string
	GetNickname() string
	GetUUID() uuid.UUID
	GetUserId() uint
	GetUserInfo() any
	GetAuthorityId() uint
}

func (a *AppUser) GetOpenid() string {
	return a.Openid
}

func (a *AppUser) GetNickname() string {
	return a.NickName
}

func (a *AppUser) GetUUID() uuid.UUID {
	return a.UUID
}

func (a *AppUser) GetUserId() uint {
	return a.ID
}

func (a *AppUser) GetUserInfo() any {
	return *a
}

// GetAuthorityId TODO: 暂时写死
func (a *AppUser) GetAuthorityId() uint {
	return 888
}
